package com.future.lottie;

import android.app.Activity;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.future.lottie.activity.AudioActivity2;
import com.future.lottie.activity.BottomNavigationActivity;
import com.future.lottie.activity.DrawerActivity;
import com.future.lottie.activity.MainActivity;
import com.future.lottie.activity.Proxyctivity;
import com.future.lottie.activity.SettingActivity;
import com.future.lottie.base.BaseActivity;
import com.future.lottie.base.BaseAdapter;
import com.future.lottie.base.BaseViewHolder;
import com.future.lottie.databinding.ActivityLaunchBinding;
import com.future.lottie.databinding.ItemPageListBinding;

import java.util.Arrays;

public class LaunchActivity extends BaseActivity<ActivityLaunchBinding> {


    @Override
    protected ActivityLaunchBinding createViewBinding(LayoutInflater inflater) {
        return ActivityLaunchBinding.inflate(inflater);
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {
        RecyclerView recyclerView = mViewBinding.getRoot();
        PageAdapter pageAdapter = new PageAdapter();
        pageAdapter.addAll(Arrays.asList(
                MainActivity.class,
                DrawerActivity.class,
                SettingActivity.class,
                BottomNavigationActivity.class,
                AudioActivity2.class,
                Proxyctivity.class));
        recyclerView.setAdapter(pageAdapter);


        getLifecycle().addObserver(new Ob());
    }


    class PageAdapter extends BaseAdapter<Class<? extends Activity>, ItemPageListBinding> {

        @Override
        public void onBindViewHolder(@NonNull BaseViewHolder<ItemPageListBinding> holder, int position) {

            Class<? extends Activity> item = getItem(position);
            holder.mViewBinding.tvItem.setText(item.getSimpleName());
            holder.itemView.setOnClickListener(v -> startActivity(new Intent(LaunchActivity.this, item)));
        }

        @Override
        protected ItemPageListBinding getViewBinding(@NonNull LayoutInflater inflater,
                                                     @NonNull ViewGroup parent, int viewType) {
            return ItemPageListBinding.inflate(inflater, parent, false);
        }
    }

}
